<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/logic/CustomCommand.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/DaoFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];
	
	/*
	* Class to validate a credential
	*/
	class CommandChangePurchaseOrder extends CustomCommand {
		/*
		* Constructor of the class
		*/
	public function __construct($pkNumber, $pkControlNumber, $date, $tax, $readStatus, 
			$fkIdNumberNaturalCustomer, $fkRifLegalClient) {
			$this -> pkNumber = $pkNumber;
			$this -> pkControlNumber = $pkControlNumber;
			$this -> date = $date;
			$this -> tax = $tax;
			$this -> readStatus = $readStatus;
			$this -> fkIdNumberNaturalCustomer = $fkIdNumberNaturalCustomer;
			$this -> fkRifLegalClient = $fkRifLegalClient;
		}
		
		/*
		* Method to execute to validate the credential
		*/
		public function execute() {
			//Ir contra el DAO con este query

			$daoFactory= DaoFactory:: getMySqlDaoFactory();
			$iuad= $daoFactory-> getMySqlPurchaseOrderAccessDao();			
			$success=$iuad->changePurchaseOrder($this ->pkNumber, $this ->pkControlNumber, $this ->date, $this ->tax, $this ->readStatus, $this ->fkIdNumberNaturalCustomer, $this ->fkRifLegalClient);
	
			
			//Si existe la credencial el resultado es true
			$this -> result = $success;
		}
	}
?>